package com.googlecode.connectlet.machine.provider.signature;

import com.googlecode.connectlet.crypto.digest.SignatureStream;
import com.googlecode.connectlet.machine.provider.MachineKey;
import com.googlecode.connectlet.machine.provider.key.MachinePrivateKey;
import com.googlecode.connectlet.util.Bytes;

public abstract class MachineSignatureStream extends SignatureStream {
	private static final long serialVersionUID = 1L;

	private MachinePrivateKey privateKey = null;
	private MachineKey machineKey = null;

	protected abstract byte[] getHeader();

	protected MachineSignatureStream(MachinePrivateKey privateKey, MachineKey machineKey) {
		this.privateKey = privateKey;
		this.machineKey = machineKey;
	}

	@Override
	public byte[] sign() {
		return machineKey.sign(privateKey, Bytes.add(getHeader(), digest()));
	}

	@Deprecated
	@Override
	public boolean verify(byte[] sigBytes) {
		throw new UnsupportedOperationException();
	}
}